#include <stdio.h>

/* 算法0-0：求两个非负整数的最大公约数GCD(x, y) */
int GCD(int x, int y) {
    int r;

    if (x < y) { /*若x<y则交换二者，保证开始计算时x>=y*/
        r = x;
        x = y;
        y = r;
    }
    while (x % y) {
        r = x % y;
        x = y;
        y = r;
    }
    return y;
}
/* 算法0-0 结束 */

int main(void) {
    int x, y;

    scanf("%d %d", &x, &y);
    printf("%d\n", GCD(x, y));
    return 0;}